package system.base;

import framework.core.*;

/*
 Author    :chengbiao.he
 CreateTime:2008-02-14 08:38:58
 */
public class ProductUpdatePriceSearchEvent extends SearchEvent {

	private String m_id = ""; // 序号

	private String m_product_id = ""; // 产品ID

	private String m_concentricity_code = "";// 产品集中编码

	private double m_before_price = Value.NULL_DOUBLE; // 调价前价格

	private double m_after_price = Value.NULL_DOUBLE; // 调价后价格

	private String m_create_user_id = ""; // 创建人序号

	private String m_create_user = ""; // 创建人

	private String m_create_time = ""; // 创建时间

	private String m_auditing_user_id = ""; // 审批人序号

	private String m_auditing_user = ""; // 审批人

	private String m_auditing_time = ""; // 审批时间

	private String m_auditing_status = ""; // 审批状态

	private String m_enabled_time = ""; // 启用时间

	private String m_status = ""; // 是否有效
	
	private String m_product_name = ""; // 产品名称
	
	private String m_model = "" ; // 型号

	private String m_spec = "" ; // 规格
	
	private String m_drawing_piece_code = "" ; // 图件号
	
	private String m_provider_code = "" ; // 供应商

	private String m_enabled_time_start = ""; 
	
	private String m_enabled_time_end = "";
	
	private String m_show_type = "";

	private String m_is_first = "";
	
	private String currentWarehouseCode = "";
	
    public ProductUpdatePriceSearchEvent() {
        super();
        setOrderField(ProductUpdatePrice.ID);
    }
    
	public String getCurrentWarehouseCode() {
		return currentWarehouseCode;
	}
	public void setCurrentWarehouseCode(String currentWarehouseCode) {
		this.currentWarehouseCode = currentWarehouseCode;
	}

    public String getIsFirst()
	{
		return m_is_first;
	}
	public void setIsFirst(String v)
	{
		m_is_first = v;
	}
    
    public String getShowtype()
	{
		return m_show_type;
	}
	public void setShowType(String v)
	{
		m_show_type = v;
	}
	

	public String getId()
	{
		return m_id;
	}
	public void setId(String v)
	{
		m_id = v;
	}
	

	public String getCreateUserId()
	{
		return m_create_user_id;
	}
	public void setCreateUserId(String v)
	{
		m_create_user_id = v;
	}
	

	public String getCreateUser()
	{
		return m_create_user;
	}
	public void setCreateUser(String v)
	{
		m_create_user = v;
	}
	

	public String getCreateTime()
	{
		return m_create_time;
	}
	public void setCreateTime(String v)
	{
		m_create_time = v;
	}
	
	
	public String getProductId()
	{
	    return m_product_id;
	}
	public void  setProductId(String v)
	{
		m_product_id = v ;
	}
	
	public String getProductName()
	{
	    return m_product_name;
	}
	public void  setProductName(String v)
	{
		m_product_name = v ;
	}
	
	public String getModel()
	{
	    return m_model;
	}
	public void  setModel(String v)
	{
		m_model = v ;
	}
	
	public String getSpec()
	{
	    return m_spec;
	}
	public void  setSpec(String v)
	{
		m_spec = v ;
	}
	
	public String getConcentricityCode()
	{
	    return m_concentricity_code;
	}
	
	public void  setConcentricityCode(String v)
	{
		m_concentricity_code = v ;
	}
	
	public double getBeforePrice()
	{
	    return m_before_price;
	}
	public void  setBeforePrice(double v)
	{
		m_before_price = v ;
	}
	
	public double getAfterPrice()
	{
	    return m_after_price;
	}
	
	public void  setAfterPrice(double v)
	{
		m_after_price = v ;
	}

	public String getAuditingUserId()
	{
	    return m_auditing_user_id;
	}
	public void  setAuditingUserId(String v)
	{
		m_auditing_user_id = v ;
	}

	public String getAuditingUser()
	{
	    return m_auditing_user;
	}
	public void  setAuditingUser(String v)
	{
		m_auditing_user = v ;
	}

	public String getAuditingTime()
	{
	    return m_auditing_time;
	}
	public void  setAuditingTime(String v)
	{
		m_auditing_time = v ;
	}
	
	public String getAuditingStatus()
	{
	    return m_auditing_status;
	}
	public void  setAuditingStatus(String v)
	{
		m_auditing_status = v ;
	}
	
	public String getEnabledTime()
	{
	    return m_enabled_time;
	}
	public void  setEnabledTime(String v)
	{
		m_enabled_time = v ;
	}
	
	public String getEnabledTimeStart()
	{
	    return m_enabled_time_start;
	}
	public void  setEnabledTimeStart(String v)
	{
		m_enabled_time_start = v ;
	}
	
	public String getEnabledTimeEnd()
	{
	    return m_enabled_time_end;
	}
	public void  setEnabledTimeEnd(String v)
	{
		m_enabled_time_end = v ;
	}

	public String getDrawingPieceCode()
	{
		return m_drawing_piece_code;
	}
	public void setDrawingPieceCode(String v)
	{
		m_drawing_piece_code = v;
	}
	
	public String getProviderCode()
	{
		return m_provider_code;
	}
	public void setProviderCode(String v)
	{
		m_provider_code = v;
	}

	public String getStatus()
	{
		return m_status;
	}
	public void setStatus(String v)
	{
		m_status = v;
	}
	

	public String viewId() throws Exception
	{
		return Value.view(getId());
	}
	
	public String viewProductId() throws Exception
	{
		return Value.view(getProductId());
	}
	
	public String viewProductName() throws Exception
	{
		return Value.view(getProductName());
	}
	
	public String viewSpec() throws Exception
	{
		return Value.view(getSpec());
	}
	
	public String viewModel() throws Exception
	{
		return Value.view(getModel());
	}
	
	public String viewDrawingPieceCode() throws Exception
	{
		return Value.view(getDrawingPieceCode());
	}
	
	public String viewConcentricityCode() throws Exception
	{
		return Value.view(getConcentricityCode());
	}

	public String viewBeforePrice() throws Exception
	{
		return Value.view(getBeforePrice());
	}
	
	public String viewAfterPrice() throws Exception
	{
		return Value.view(getAfterPrice());
	}
	
	public String viewCreateUserId() throws Exception
	{
		return Value.view(getCreateUserId());
	}

	public String viewCreateUser() throws Exception
	{
		return Value.view(getCreateUser());
	}

	public String viewCreateTime() throws Exception
	{
		return Value.view(getCreateTime());
	}
	
	public String viewAuditingUserId() throws Exception
	{
		return Value.view(getAuditingUserId());
	}

	public String viewAuditingUser() throws Exception
	{
		return Value.view(getAuditingUser());
	}

	public String viewAuditingTime() throws Exception
	{
		return Value.view(getAuditingTime());
	}
	
	public String viewAuditingStatus() throws Exception
	{
		return Value.view(getAuditingStatus());
	}

	public String viewEnabledTime() throws Exception
	{
		return Value.view(getEnabledTime());
	}

	public String viewStatus() throws Exception
	{
		return Value.view(getStatus());
	}

    public Conditions toConditions() throws Exception {
        Conditions c = super.toConditions();

    	c.add(getCondition(ProductUpdatePrice.CONCENTRICITY_CODE,getConcentricityCode()));
    	
        if(!getStatus().equalsIgnoreCase("")){
        	if("0".equals(getStatus())){
        		  c.add(ProductUpdateIsbuy.STATUS, Conditions.NOT_EQUAL,1);	
        	}else{
        		  c.add(ProductUpdateIsbuy.STATUS,Conditions.EQUAL,1);	
        	}
        }
    	
    	c.add(getCondition(ProductUpdatePrice.AUDITING_STATUS,getAuditingStatus()));
        
        if(!getEnabledTimeStart().equalsIgnoreCase(""))
        {
            c.add(" ENABLED_TIME >= ?", Conditions.CUSTOM, getEnabledTimeStart());
        }
        
        if(!getEnabledTimeEnd().equalsIgnoreCase(""))
        {
            c.add(" ENABLED_TIME <= ?", Conditions.CUSTOM, getEnabledTimeEnd()+" 23:59:59");
        }
        
      String sql= ProductUpdatePrice.PRODUCT_ID + " in (select product_id from t_product_update_price a,t_product b,t_provider c where a.CONCENTRICITY_CODE = b.CONCENTRICITY_CODE and b.provider_code=c.code ";
       
      sql+=" and (b.warehouse_code='00' ";
       if(!getCurrentWarehouseCode().equals("")){
    	   sql+=" or b.warehouse_code like '%"+getCurrentWarehouseCode()+"%'";
       }
       sql+=" ) ";
       if(!getProductName().equals("")){
    	   sql+=" and b.name like '%"+getProductName()+"%'";
       }
       
       if(!getSpec().equals("")){
    	   sql+=" and b.spec like '%"+getSpec()+"%'";
       }
       
       if(!getModel().equals("")){
    	   sql+=" and b.model like '%"+getModel()+"%'";
       }
       
       if(!getDrawingPieceCode().equals("")){
    	   sql+=" and b.drawing_piece_code like '%"+getDrawingPieceCode()+"%'";
       }
       
       if(!getProviderCode().equals("")){
    	   sql+=" and c.name like '%"+getProviderCode()+"%'";
       }
      sql+=")";
      c.add(sql);
      return c;
    }

}
